﻿@using MvcPaging
@using QuocHoi_TV_Frontend.Models;
@model IPagedList<QuocHoi_TV_Frontend.Models.NewsModel>
<div class="othernews">
<ul>
    @{int i = 0;}
    @foreach (NewsModel item in Model)
    {
        string strlinkNews = Url.RouteUrl("NewsDetail",
            new
            {
                controller = "News",
                action = "NewsDetailHome",
                cate_name = Util.RemoveSign4VietnameseString(item.CateName),
                year = DateTime.Parse(item.CreateDate.ToString()).Year,
                month = DateTime.Parse(item.CreateDate.ToString()).Month,
                news_title = Util.RemoveSign4VietnameseString(item.NewsTitleUnsign),
                newsID = item.NewsID
            }
                );
       
            <li>
                <div class="img_othernews">
                    <a href="@Html.Raw(strlinkNews)">
                        <img width="198" height="109" src="@item.PathImgSmall">
                    </a>
                </div>
                <div class="info_othernews">
                    <div class="day_ifon">@Html.Raw(UtilDate.FormatDateVN(DateTime.Parse(item.CreateDate.ToString())))</div>
                    <div class="tile_ifon">
                        <a href="@Html.Raw(strlinkNews)">@Html.Raw(item.NewsTitle)</a>
                    </div>
                    <div class="excerpts_ifon">@Html.Raw(NewsHelper.Sliptsubject(item.NewSub, 130))</div>
                </div>
            </li>											
        

        i++;
    }

</ul>
</div>
<div class="next_page_on">
	@Html.Raw(Ajax.Pager(
    new Options
    {
        PageSize = Model.PageSize,
        TotalItemCount = Model.TotalItemCount,
        CurrentPage = Model.PageNumber,
        ItemTexts = new ItemTexts() { Next = "", Previous = "", Page = "", First = "", Last = "" },
        ItemIcon = new ItemIcon() { First = "icon-backward", Previous = "icon-chevron-left", Next = "icon-chevron-right", Last = "icon-forward" },
               
        Size = Size.normal,
        Alignment = Alignment.left,
        IsShowControls = true,
        IsShowFirstLast = true
       
    },
    new AjaxOptions
    {
        UpdateTargetId = "grid-list",
        OnBegin = "beginPaging",
        OnSuccess = "successPaging",
        OnFailure = "failurePaging"
    }, new { controller = "Search", action = "Index", searchTerm = ViewData["keyword"]}))
</div>
<script type="text/javascript">

    function beginPaging(args) {
        // Animate
        //$('#grid-list').fadeOut('normal');
    }

    function successPaging() {
        // Animate
        //$('#grid-list').fadeIn('normal');
        //$('a').tooltip();
    }

    function failurePaging() {
        alert("Could not retrieve list.");
    }

    function searchFailed() {
        $("#grid-list").html("Sorry, there was a problem with the search.");
    }

</script>